import { getListApi } from "@/api/configCenter/invoicesManagement";
import { reactive, ref } from "vue";

export default function InitHook() {
  const formState = reactive<{
    bizExportTemplateId: string | undefined;
  }>({
    bizExportTemplateId: undefined
  });
  const formDataRef = ref<any>(null);
  const loading = ref<boolean>(false);
  const invoiceTemplateOpts = ref<Array<Base.GeneraDataType>>([]);
  const getAllInvoiceTemplate = () => {
    return getListApi({ pageNum: 1, pageSize: 99999 } as invoicesManagement.SearchForm).then((res: any) => {
      const { code, data } = res;
      if (code === 200) {
        invoiceTemplateOpts.value = data.records || [];
      }
    });
  };
  return {
    formState,
    formDataRef,
    invoiceTemplateOpts,
    getAllInvoiceTemplate,
    loading
  };
}
